﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Reflection;

namespace CodeArt.SharePoint.Configuration
{
    using System.Configuration;
    using Microsoft.SharePoint;
    using Microsoft.SharePoint.Utilities;


    public class ConfigurationTextElement : ConfigurationElement
    {
        private string _value;
        protected override void DeserializeElement(XmlReader reader, bool serializeCollectionKey)
        {
            if (reader.AttributeCount > 0)
            {
                //reader.MoveToFirstAttribute();
                foreach (ConfigurationProperty configurationProperty in Properties)
                {
                    string name = configurationProperty.Name;
                    string attributeValue = reader.GetAttribute(name);
                    base[name] = attributeValue;
                }
            }

            reader.MoveToElement();
            if (!reader.IsEmptyElement)
            {
                //if ((reader.NodeType == XmlNodeType.CDATA) || (reader.NodeType == XmlNodeType.Text))
                //{
                    _value = (string)reader.ReadElementContentAs(typeof(string), null);
                //}
            }
            this.PostDeserialize();

        }
        public string Value
        {
            get { return _value; }
        }
    }


}
